<%@ page language="java" contentType="text/html; charset=utf-8"
         pageEncoding="utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>后台管理 - 易买网</title>
    <link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/admin/css/style.css"/>
    <script type="text/javascript" src="${pageContext.request.contextPath}/admin/scripts/function-manage.js"></script>
    <script src="${pageContext.request.contextPath}/js/jquery.js" type="text/javascript"></script>
    <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.0.2/css/bootstrap.min.css" rel="stylesheet">
    <script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.0.2/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/page.css">
</head>
<body>
<div id="header" class="wrap">
    <div id="logo"><img src="../images/logo.gif"/></div>
    <div class="help"><a href="${pageContext.request.contextPath}/index.jsp">返回前台页面</a></div>
    <div class="navbar">
        <ul class="clearfix">
            <li><a href="${pageContext.request.contextPath}/admin/manage/index.jsp">首页</a></li>
            <li><a href="${pageContext.request.contextPath}/manageUser">用户</a></li>
            <li class="current"><a href="javascript:void(0)">商品</a></li>
            <li><a href="${pageContext.request.contextPath}/admin/manage/order.jsp">订单</a></li>
        </ul>
    </div>
</div>
<div id="childNav">
    <div class="welcome wrap">
        管理员pillys您好，今天是2012-12-21，欢迎回到管理后台。
    </div>
</div>
<div id="position" class="wrap">
    您现在的位置：<a href="${pageContext.request.contextPath}/admin/manage/index.jsp">易买网</a> &gt; 管理后台
</div>
<div id="main" class="wrap">
    <div id="menu-mng" class="lefter">
        <div class="box">
            <dl>
                <dt>用户管理</dt>
                <dd>
                    <em><a href="${pageContext.request.contextPath}/admin/manage/user-add.jsp">新增</a></em>
                    <a href="${pageContext.request.contextPath}/manageUser">用户管理</a>
                </dd>
                <dt>商品信息</dt>
                <dd><em><a href="${pageContext.request.contextPath}/admin/manage/product-add.jsp">新增</a></em>
                    <a href="javascript:void(0)">商品管理</a>
                </dd>
                <dt>订单管理</dt>
                <dd><a href="${pageContext.request.contextPath}/admin/manage/order.jsp">订单管理</a></dd>
            </dl>
        </div>
    </div>
    <div class="main">
        <h2>商品管理</h2>
        <h4>${msg}</h4>
        <div class="manage">
            <table class="list">
                <tr>
                    <th>ID</th>
                    <th>商品名称</th>
                    <th>操作</th>
                </tr>
                <c:forEach items="${page.lists }" var="pro">
                    <tr>
                        <td class="first w4 c">${pro.gid }</td>
                        <td class="thumb"><a href="#" target="_blank">${pro.gname }</a></td>
                        <td class="w1 c">
                            <a href="${pageContext.request.contextPath}/admin/manage/adminfindbygid.do?gid=${pro.gid}">修改</a>
                            <a href="#" onclick="delGoods(${pro.gid })">删除</a>
                        </td>
                    </tr>
                </c:forEach>

            </table>
        </div>
    </div>
    <script type="text/javascript">
        function delGoods(gid) {
            $.get("${pageContext.request.contextPath}/deleteGoodsByGid",{gid:gid},(data,status) => {
                if (data === "1") {
                    alert("success")
                    location.reload()
                } else {
                    alert("error")
                }
            });
        }
    </script>
    <div class="clear"></div>
    <br>
    <div id="page-normal">
        <c:choose>
            <c:when test="${page.nowpage eq 1}">
                <a id="page-prev" href="" style="pointer-events:none"><i></i>上一页</a>
            </c:when>
            <c:otherwise>
                <a id="page-prev" href="${page.url}&nowpage=${page.nowpage-1}"><i></i>上一页</a>
            </c:otherwise>
        </c:choose>

        <c:forEach begin="1" end="${page.totalpage}" step="1" var="i">
            <c:choose>
                <c:when test="${page.nowpage eq i}">
                    <a class="page-current" href="${page.url}&nowpage=${i}"> ${i} </a>
                </c:when>
                <c:otherwise>
                    <a href="${page.url}&nowpage=${i}"> ${i} </a>
                </c:otherwise>
            </c:choose>
        </c:forEach>
        <c:choose>
            <c:when test="${page.nowpage eq page.totalpage}">
                <a id="page-next" href="#" style="pointer-events:none">下一页<i></i></a>
            </c:when>
            <c:otherwise>
                <a id="page-next" href="${page.url}&nowpage=${page.nowpage+1}">下一页<i></i></a>
            </c:otherwise>
        </c:choose>
    </div>
</div>
<div id="footer">
    Copyright &copy; 2010 中软国际 All Rights Reserved. 京ICP证1000001号
</div>
</body>
</html>
    